package org.yray.sip.handler.flow;


import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.yray.sip.base.SipMsg;
import org.yray.sip.constant.SipCodeEnum;
import org.yray.sip.handler.MessageHandler;
import org.yray.sip.server.SipServerContext;
import org.yray.sip.visit.ISipAccept;
import org.yray.sip.visit.SipVisitorFactory;

@Slf4j
public class Progress183Handler extends MessageHandler {


    @Override
    public String[] handler(SipMsg sipMsg, SipServerContext ssc) {
        sipMsg.setSipCode(SipCodeEnum.SIP_183);
        if(CollectionUtils.isEmpty(sipMsg.getSdpList())) {
            log.info("recv Progress 183,nothing to send");
            return BLANK_STRINGS;
        }
        String callId= sipMsg.getCallId();
        ISipAccept sipAccept=getSipVisitorFactory().getSipAccept(callId);
        sipAccept.accept(SipVisitorFactory.SIP_183_VISITOR,sipMsg,ssc);
        return BLANK_STRINGS;

    }

}
